<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="Access-Control-Allow-Origin" content="*" />
		<title>迟到信息列表</title>
		<script type="text/javascript" src="js/vue.js"></script>
		<script src="https://cdn.staticfile.org/vue-resource/1.5.1/vue-resource.min.js"></script>
		
		<script type="text/javascript" src="js/ajax.js"></script>
		<script type="text/javascript" src="js/jquery-1.7.2.js"></script>
		<style type="text/css">
			#addDelay-student{
				width:500px;
				margin: auto;

			}
			#addDelay-student td{
				text-align: center;
				border: 1px gray solid;
			}
		</style>
	</head>
	<body>
		
		<table id="addDelay-student" cellspacing="1" cellpadding="0">
			
			<tr>
				<td></td>
				<td>学生ID</td>
				<td>姓名</td>
				
			</tr>
			<tr v-for="student in students"  >
				<td><input type="checkbox" v-bind:value="student.id" v-model="userId"/></td>
				<td >{{student.id}}</td>
				<td >{{student.name}}</td>
								
			</tr>
			<tr>
				<td colspan="3"><input type="date" v-model="delayDate" /></td>
			
			</tr>
			<tr>
				<td colspan="3"><input type="button"   value="新增" v-on:click="add"/></td>
			
			</tr>
		</table>
		
	</body>
	<script>
	

	    
	    window.onload = function(){
			var vue = new Vue({
				
				el:"#addDelay-student",
				data:{
					userId:[],
					delayDate:'',
					students:{},
				},
				methods:{
					get:function(){
					
						var url = "http://localhost:8080/kaoqin/delay/addInit.do";
						var data='';
						getsend(url,data,function(rs){
							
							
							
							vue.students = rs.data;
							
							
						});
					},
					
					add:function(){
						
						var url = "http://localhost:8080/kaoqin/delay/add.do";
						var delayBeanList=new Array();
						for(var index =0; index<vue.userId.length;index++){
							var id = vue.userId[index];
							var delayBean={
								"userId":id,
								"delayDate":vue.delayDate
							}
							delayBeanList[index]=delayBean;
						}
						var data=JSON.stringify(delayBeanList);
						postsend(url,data,function(rs){
							console.log(rs)
							
						});
						
						
					},
					
					
				}
			});
		    vue.get();
			
		}
		
	</script>
</html>
